package com.szxy.annotationtest;

import com.sun.istack.internal.NotNull;

import java.lang.reflect.Method;

/**
 * @Author: zwz
 * @Date:2020/9/30 16:46
 * @Description:com.szxy
 * @Version:1.0
 **/
public class Annotationtest {

    private @NotNull Object obj;

    public static void main(String[] args) throws NoSuchMethodException {
        Class<Annotationtest> clazz = Annotationtest.class;
        Method showMethod = clazz.getMethod("show");
        // 获取注解
        MyAnnotation[] annotations = showMethod.getAnnotationsByType(MyAnnotation.class);
        for (MyAnnotation annotation : annotations) {
            System.out.println(annotation.value());
        }
    }

    @MyAnnotation("Hello")
    @MyAnnotation("World")
    public void show() {
        System.out.println("test ...");
    }

}
